package utils;

import org.jvnet.inflector.Noun;


import junit.framework.TestCase;
public class WordUtilsTest extends TestCase {

	public void testPlurals() {
		assertEquals(pluralize("knife"), "knives");
		assertEquals(pluralize("day"), "days");
		assertEquals(pluralize("calf"), "calves");
		assertEquals(pluralize("branch"), "branches");
		assertEquals(pluralize("fox"), "foxes");
		assertEquals(pluralize("loaf"), "loaves");
		assertEquals(pluralize("thief"), "thieves");
		assertEquals(pluralize("man"), "men");
		assertEquals(pluralize("woman"), "women");
		assertEquals(pluralize("bottle of water"), "bottles of water");
	}

	public void testNumberedPlurals() {
		assertEquals(pluralize("knife", 10), "ten knives");
		assertEquals(pluralize("day", 5), "five days");
		assertEquals(pluralize("calf", 32), "many calves");
		assertEquals(pluralize("branch", 1020), "thousands of branches");
		assertEquals(pluralize("fox", 2), "two foxes");
		assertEquals(pluralize("thief", 40), "many thieves");
		assertEquals(pluralize("bottle of water", 1000000), "thousands of bottles of water");
	}
	void testAAn(){
		def list = ["ship", "test", "cow", "hour", "union", "solid", "aardvark", "one-sided","honourable","onion","euphoric","u","s","x","MIT","AAA","f","i", "sheep"]
		def correct = ["a ship", "a test", "a cow", "an hour", "a union", "a solid", "an aardvark", "a one-sided","a honourable","an onion","a euphoric","a u","an s","an x","an MIT","a AAA","an f","an i", "a sheep"]
		list.eachWithIndex{ it, idx ->
			def val = affixIndefiniteArticle(it)
			assert val == correct[idx], "failed: $val != ${correct[idx]}"
		}
	}
}
